#!/usr/bin/python
# -*- coding: UTF-8 -*-
import requests
from bs4 import BeautifulSoup ## -*- coding: UTF-8 -*-

#request requests
r = requests.get('http://www.wise.xmu.edu.cn/people/faculty')
html = r.content

'''
r3 = requests.get('http://www.cninfo.com.cn/finalpage/2015-03-13/1200694563.PDF',stream = True)    #请求
r3.raw.read()   #读取文件（最好在括号里面加一下个数，只读前面几个，不然……可以试试看哈哈哈哈）

post_data={
'stock':'000001',
'searchkey':'',
'category':'category_ndbg_szsh;',
'pageNum':'1',
'pageSize':'',
'column':'szse_main',
'tabName':'fulltext',
'sortName':'',
'sortType':'',
'limit':'',
'seDate':''
}
r2 = requests.post('http://www.cninfo.com.cn/cninfo-new/announcement/query',data=post_data)    #post方法

r1.status_code    #状态码，正常是200 3重定向 4客户端异常 5服务器异常
r1.encoding    #文件编码，比如'utf-8'
r1.content    #文件全文
r1.json()    #把请求回来的json数据转成Python字典并返回
'''

#parser bs4
soup = BeautifulSoup(html,'html.parser')
div_people_list = soup.find('div', attrs={'class': 'people_list'})
a_s = div_people_list.find_all('a', attrs={'target': '_blank'})
out = []

for a in a_s:
	url = a['href']
	name = a.get_text()
	out.append([url, name])
	print name,url
#save
fo = open('1.txt', "wb")
for a in out:
	fo.write("%s %s\r\n" % (a[0],a[1]))
	
#print out

#if __name__ == "__main__":

	
	